<!-- 动画按钮 动画问题-->
<template>
  <div class="btn">
    <NuxtLink :to="props.href">
      <button :style="'width: ' + props.width + '; height: ' + props.height">
        <div class="title">{{ props.title }}</div>
      </button>
    </NuxtLink>
  </div>
</template>

<script setup>
const props = defineProps({
  title: {
    type: String,
    required: "标题",
  },
  width: {
    type: String,
    default: "200px",
  },
  height: {
    type: String,
    default: "50px",
  },
  href: {
    type: String,
    default: "/",
  },
});
</script>

<style lang="scss" scoped>
@import "@/assets/styles/theme.scss";
button {
  width: 100%;
  height: 100%;
  position: relative;
  padding: 10px;
  border-radius: 3px;
  font-size: 18px;
  background-color: #fff;
  color: #6ddccb;
  border: 2px solid #6ddccb;
  cursor: pointer;
  transition: background-color 0.3s ease;
  
  & a {
    width: 100%;
    height: 100%;
  }
  .title{
    font-size: 16px;
    text-align: center;
    line-height: 1.5;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #6ddccb;
    z-index: 99;
  }
}

button::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 100%;
  background-color: rgb(2, 201, 171);
  transition: all 0.5s ease-in-out;
  opacity: 0;
  border-radius: 2px;
  
}
button:hover {
  border: none;
  
  &::after {
    z-index: 79;
    opacity: 1;
    width: 100%;
    left: 0;
  }
  .title{
    color: #fff;
  }
}

.btn {
  display: flex;
  justify-content: center;
  margin-top: 50px;
}
</style>
